package com.lenovo.order_service.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Getter
public enum OrderStatus {
    PENDING("PENDING","待处理"),
    COMPLETED("COMPLETED","已完成");
    private String status;

    private String name;

    OrderStatus(String status, String name) {
        this.status = status;
        this.name = name;
    }

    private static Map<String, OrderStatus> cache;

    static {
        cache = Arrays.stream(OrderStatus.values()).collect(Collectors.toMap(OrderStatus::getStatus, Function.identity()));
    }
    public static OrderStatus of(String status) {
        return cache.get(status);
    }

}
